﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace P2PLib.Client.Command
{
    public class CCCurrentPositionCommand:CCCommandBase
    {
        private long position;

        public long Position
        {
            set
            {
                this.position = value;
            }
            get
            {
                return this.position;
            }
        }

        public CCCurrentPositionCommand()
            : base(CCCommandType.CurrentPosition)
        {
            this.position = 0;
        }

        public CCCurrentPositionCommand(long pos)
            : base(CCCommandType.CurrentPosition)
        {
            this.position = pos;
        }

        public override void ReadFromStream(System.IO.Stream stream)
        {
            byte[] buffer = new byte[8];
            stream.Read(buffer,0,8);
            long pos = BitConverter.ToInt64(buffer,0);
            this.position = pos;
        }

        public override void WriteToStream(System.IO.Stream stream)
        {
            byte[] buffer = BitConverter.GetBytes(this.position);
            stream.Write(buffer,0,buffer.Length);
        }

    }
}
